stack_segment SEGMENT
    dw 100 dup(?)
    tos label word
stack_segment ENDS
code SEGMENT
    assume ss:stack_segment, cs:code
output_number proc near
    mov bp, sp
    pushf
    push ax
    push bx
    push cx
    push dx
    push bp
    mov cx, [bp+2]
    cmp cx, 0
    jge positive
    mov dl, '-'
    mov ah, 2
    int 21h
    neg cx
positive:
    mov bx, 10
    mov bp, sp
calculate_each:
    mov dx, 0
    mov ax, cx
    div bx
    add dx, '0'
    push dx
    mov cx, ax
    test cx, 0ffffh
    jne calculate_each
    mov ah, 2
output:
    cmp bp, sp
    je exit
    pop dx
    int 21h
    jmp output
exit:
    pop bp
    pop dx
    pop cx
    pop bx
    pop ax
    popf
    ret
output_number endp
start:
    mov ax, stack_segment
    mov sp, ax;0770h
    mov ah, 2
    mov dl, 10
    mov cx, 0ffffh
    push cx
    call output_number
    int 21h
    mov ax, 4c00h
    int 21h
code ENDS
end start